/* 
 * File:   resource.h
 * Author: Faraj
 *
 * Created on May 5, 2013, 6:38 PM
 */

#ifndef RESOURCE_H
#define	RESOURCE_H

#include <string>
#include <vector>
#include <fstream>
#include "config.h"
#include "common/log.h"
#include "../lib/application.h"
using namespace std;

namespace lib {

    class resource {
    public:
        resource(string path);
        bool is_valid();
        bool is_valid_folder();
        string get_path();
        int get_size();
        FILE* get_fd();
        bool is_data_file();
        bool open();
        bool read();
        void execute();
        bool close();
        char* get_content();
        virtual ~resource();
        static void conf_apps(config *conf, string root_key);
        static void add_application(string name, vector<string> params);
    private:
        bool _valid;
        string _path;
        string _mime;
        char *_content;
        ifstream _file;
        int _size;
        static vector<application> _applications;
    };
};
#endif	/* RESOURCE_H */

